package com.atlbb.service.Impl;

import com.atlbb.dao.UserDao;
import com.atlbb.mybatis.entity.User;
import com.atlbb.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author LiangQingBin
 * @version 1.00
 * @ClassName UserServiceImpl
 * @Description TODO
 * @time 2021/11/7 14:55
 */
@Service
@Transactional//控制事务
public class UserServiceImpl implements UserService {
    @Autowired
  private  UserDao userDao;
    
    @Override
    public List<User> findAll() {
        return userDao.findAll();
    }
    
    @Override
    public void saveOne(User user) {
        userDao.saveOne(user);
    }
    
    @Transactional(propagation = Propagation.SUPPORTS)
    @Override
    public void deleteOneById(Integer id) {
        userDao.deleteOneById(id);
    }
    
    //更新一个用户
    @Override
    public void updateOne(User user) {
        userDao.updateOne(user);
    }
    
    //分页查询
    @Override
    public List<User> findByPage(Integer start, Integer rows) {
        return userDao.findByPage(start,rows);
    }
    
    //查询总数
    @Override
    public Long findCount() {
       return userDao.findCount();
    }
}
